package cn.com.pajx.pajx_visitor_v3.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import cn.com.pajx.pajx_visitor_v3.ui.activity.SplashActivity;

/**
 * Created by ruancw on 2024/2/28.
 * Description:开机自启动广播监听
 */
public class AutoStartReceiver extends BroadcastReceiver {

    public static final String BOOT_ACTION = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {

        if (BOOT_ACTION.equals(intent.getAction()) || Intent.ACTION_MEDIA_MOUNTED.equals(intent.getAction())) {
            Intent myIntent = new Intent(context.getApplicationContext(), SplashActivity.class);
            myIntent.setAction("android.intent.action.MAIN");
            myIntent.addCategory("android.intent.category.LAUNCHER");
            myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(myIntent);

        }
    }
}
